package {
	import flash.events.*;
	import flash.geom.*;
	
	import mx.core.*;
	import mx.events.MoveEvent;
	
	public class Player extends GameObject {
		protected var fired:Boolean = false;
		public static var score:Number = 0;
		public function Player() {}
		
		public function startup():void {
			startupGameObject(ResourceManager.PinGraphics, new Point(Application.application.width / 2, Application.application.height / 2), ZOrder.PlayerZOrder);
			fired = false;
			this.collisionName = CollisionType.PLAYER;
		}
		
		public function getScore():Number {
			return score;
		}
		
		override public function shutdown():void {	
			super.shutdown();
		}
		
		override public function enterFrame(dt:Number):void {
			super.enterFrame(dt);	
		}
		
		override public function mouseMove(event:MouseEvent):void {
			position.x = event.stageX;
			position.y = event.stageY;
			
			if (position.x < 0)
				position.x = 0;			
			if (position.x > Application.application.width - graphics.bitmap.width)
				position.x = Application.application.width - graphics.bitmap.width;
			if (position.y < 0)
				position.y = 0;
			if (position.y > Application.application.height - graphics.bitmap.height)
				position.y = Application.application.height - graphics.bitmap.height;
		}
		
		override public function mouseDown(event:MouseEvent):void {	
			fired = true;
		}
		
		override public function mouseUp(event:MouseEvent):void {
			fired = false;
		}
		
		override public function collision(other:GameObject):void {
			if (fired) {
				var weapon:Weapon = Weapon.pool.ItemFromPool as Weapon;
				weapon.startupBasicWeapon(
					ResourceManager.BiscuitGraphics,	
					other.position.clone()
				);
				fired=false;
			}

		}
	}
}

